package io.spring.nn.mapper;

import io.spring.nn.bean.User;
import io.spring.nn.bean.Review;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from user")
    public List<User> getAll();

    @Insert(value = "insert into user(username, password,sex,birth) values(#{username},#{password},#{sex},#{birth})")
    public void insertUser(User user);

    @Update(value = "UPDATE user SET birth = #{birth} , sex = #{sex}, adress=#{adress} ,graph = #{graph} WHERE username=#{username}")
    public void updateUser(User user);

    @Select("select * from user where username=#{username}")
    User getUser(String username);

    @Select("select content,r_time from review WHERE id_user=#{id}")
    public List<Review> getcontent(int id);

    @Insert(value = "INSERT INTO review(content,id_user) VALUE(#{content},#{id_user})")
    public void insertContent(String content,int id_user);

//    @Select("select r_time from review WHERE id_user=#{id}")
//    public List<String> r_time(int id);
}
